<template>
    <div class="publicpageview">
        <div class="publicformview">
            <el-form :inline="true" :model="listQuery" size="mini" ref="searchForm" label-width="100px">
                <el-row :gutter="20">
                    <el-col :span="4">
                        <el-form-item label="管理单位：" prop="districtId">
                            <el-select v-model="listQuery.districtId" clearable @change="handleQuchange">
                                <el-option v-for="item in areaList" :label="item.dname" :value="item.did"
                                    :key="item.did"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>

                    <el-col :span="4">
                        <el-form-item label="管理部：" prop="houseAdminId">
                            <el-select v-model="listQuery.houseAdminId" clearable>
                                <el-option v-for="item in houseAdminList" :label="item.aname" :value="item.aid"
                                    :key="item.aid"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>

                    <el-col :span="6">
                        <el-form-item label="日期：" prop="value">
                            <el-date-picker v-model="listQuery.value" type="daterange" range-separator="-"
                                start-placeholder="年/月/日" end-placeholder="年/月/日">
                            </el-date-picker>
                        </el-form-item>
                    </el-col>

                    <el-col :span="4">
                        <el-form-item label="凭证类型：" prop="isPlanSubmission">
                            <el-select v-model="listQuery.isPlanSubmission" clearable>
                                <el-option label="否" :value="0" key="1"></el-option>
                                <el-option label="是" :value="1" key="0"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="4">
                        <el-form-item label="摘要：" prop="blockAddress">
                            <el-input v-model="listQuery.blockAddress"></el-input>
                        </el-form-item>
                    </el-col>

                    <el-col :span="4">
                        <el-form-item label="对方科目：" prop="blockAddress">
                            <el-input v-model="listQuery.blockAddress"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="4">
                        <el-form-item label="交租方式" prop="isPlanSubmission">
                            <el-select v-model="listQuery.isPlanSubmission" clearable>
                                <el-option label="否" :value="0" key="1"></el-option>
                                <el-option label="是" :value="1" key="0"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item label="两清日期：" prop="value">
                            <el-date-picker v-model="listQuery.value" type="daterange" range-separator="-"
                                start-placeholder="年/月/日" end-placeholder="年/月/日">
                            </el-date-picker>
                        </el-form-item>
                    </el-col>
                    <el-col :span="4" style="display: flex;">
                        <div style="width: 300px; padding-left: 8px;">金额区间：</div>
                        <el-form-item prop="valuejine">
                            <el-input v-model="listQuery.valuejine"></el-input>
                        </el-form-item>
                        <div style="margin-right: 9px;">-</div>
                        <el-form-item prop="valuejinee">
                            <el-input v-model="listQuery.valuejinee"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="4">
                        <div style="padding-left: 90px;">
                            <el-button size="mini" type="primary" @click="handleSearch">查询</el-button>
                            <el-button size="mini" @click="resetForm('searchForm')">重置</el-button>
                        </div>
                    </el-col>
                </el-row>
            </el-form>
        </div>

        <div class="publitableview">
            <el-button type="primary" size="mini">导出</el-button>
            <el-button type="primary" size="mini">打印</el-button>

            <el-table :data="list" border fit highlight-current-row size="mini"
                @selection-change="handleSelectionChange">
                <el-table-column type="selection" width="55" align="center">
                </el-table-column>
                <el-table-column align="center" label="日期" prop="name">
                </el-table-column>
                <el-table-column align="center" label="交租方式" prop="name">
                </el-table-column>
                <el-table-column align="center" label="凭证号" prop="name">
                </el-table-column>
                <el-table-column align="center" label="摘要" prop="name">
                </el-table-column>
                <el-table-column align="center" label="科目名称" prop="name">
                </el-table-column>
                <el-table-column align="center" label="明细科目" prop="name">
                </el-table-column>
                <el-table-column align="center" label="对方科目" prop="name">
                </el-table-column>
                <el-table-column align="center" label="借方金额" prop="name">
                </el-table-column>
                <el-table-column align="center" label="贷方金额" prop="name">
                </el-table-column>

            </el-table>
            <div class="publicpaginationview">
                <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
                    :current-page="listQuery.pageNum" background :page-sizes="[10, 20, 50, 100]"
                    :page-size="listQuery.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="total"
                    small></el-pagination>
            </div>
        </div>





    </div>
</template>

<script>

import { listAll, createPlanYear, updatePlanYear, deletePlanYear, backPlanYear, reportPlanYear } from '@/api/repair'
import { getArea, getHouseAdmin, getBlockGroup, getBlockByGroup, upload } from '@/api/common'
import { Message } from 'element-ui'
import moment from 'moment';
export default {
    name: "AccommodationManagementIndex",

    data() {
        return {
            listQuery: {
                pageNum: 1,
                pageSize: 10,
                districtId: "",
                houseAdminId: "",
                blockId: "",
                blockAddress: "",
                projectYear: "",
                repairProject: "",
                isPlanSubmission: null
            },

            total: 0,
            list: [],

            isAdd: 'add',


            areaList: [],
            houseAdminList: [],

        };
    },

    computed: {

    },

    mounted() {
        this.getCommon();
        this.getList();
    },

    methods: {
        getCommon() {
            getArea().then(res => {
                this.areaList = res.data
            })
        },

        handleQuchange(val) {
            this.listQuery.houseAdminId = null;
            if (val) {
                this.getHouseAdmin(val);

            } else {
                this.houseAdminList = [];
            }
        },



        handleReportCallback(id) {
            this.$confirm(
                "是否回退该计划",
                "提示",
                {
                    confirmButtonText: "保 存",
                    cancelButtonText: "取 消",
                    type: "warning",
                }
            )
                .then(() => {
                    backPlanYear(id).then(res => {
                        Message({
                            message: res.message || '操作成功',
                            type: "success",
                            duration: 2 * 1000,
                        });
                        this.getList();
                    })
                })
                .catch(() => { });
        },

        handleReportPass(id) {

            // this.handleReportDialogClose()
            console.log(id)
            this.$confirm(
                "是否上报该计划",
                "提示",
                {
                    confirmButtonText: "保 存",
                    cancelButtonText: "取 消",
                    type: "warning",
                }
            )
                .then(() => {
                    reportPlanYear(id).then(res => {
                        Message({
                            message: res.message || '操作成功',
                            type: "success",
                            duration: 2 * 1000,
                        });
                        this.getList();
                    })
                })
                .catch(() => { });
        },

        handleSelectionChange(val) {
            this.multipleSelection = val;
        },


        handleSizeChange(val) {
            this.listQuery.pageNum = 1;
            this.listQuery.pageSize = val;
            this.getList();
        },
        handleCurrentChange(val) {
            this.listQuery.pageNum = val;
            this.getList();
        },

        handleSearch() {
            this.listQuery.pageNum = 1;
            this.getList();
        },
        getList() {
            listAll({
                ...this.listQuery,
                projectYear: this.listQuery.projectYear ? moment(this.listQuery.projectYear).format("YYYY") : ""
            }).then((response) => {
                this.list = response.data.list;
                this.total = response.data.total;
            });
        },

        resetForm(val) {

            this.$refs[val].resetFields();
            this.listQuery.pageNum = 1;


        },



    },
};
</script>

<style scoped>
.el-date-editor--daterange.el-input,
.el-date-editor--daterange.el-input__inner,
.el-date-editor--timerange.el-input,
.el-date-editor--timerange.el-input__inner {
    width: 300px;
}
</style>